package com.example.backend.service.impl;


import com.example.backend.mapper.RestaurantMapper;
import com.example.backend.pojo.Restaurant;
import com.example.backend.pojo.User;
import com.example.backend.service.RestaurantService;
import com.example.backend.util.Md5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class RestaurantServiceImpl implements RestaurantService {
    @Autowired
    private RestaurantMapper restaurantMapper;
    @Override
    public void rejectres(String inform,String restaurantid) {
        restaurantMapper.rejectres(inform,restaurantid);
    }
    @Override
    public Restaurant getRestaurantByName(String restaurantname) {
        Restaurant u= restaurantMapper.getRestaurantByName(restaurantname);
        return u;
    }
    @Override
    public void addinform(String inform, String restaurantid) {
        restaurantMapper.addinform(inform,restaurantid);

    }


    @Override
    public void register(Restaurant restaurant) {
        restaurant.setPassword(Md5Util.getMD5String(restaurant.getPassword()));
        restaurantMapper.add(restaurant);
    }


    @Override
    public void update(Restaurant restaurant) {
        restaurant.setUpdatetime(LocalDateTime.now());
        restaurantMapper.update(restaurant);
    }

    @Override
    public void updatePwd(Integer id, String new_pwd) {
        restaurantMapper.updatePwd(id,new_pwd);
    }

    @Override
    public List<Restaurant> getall() {

        return restaurantMapper.getall();
    }

    @Override
    public void surplus(String id, Integer surplus) {
        restaurantMapper.surplus(id,surplus);
    }

    @Override
    public List<Restaurant> search(String restaurantname) {
        return restaurantMapper.search(restaurantname);
    }

    @Override
    public void normal(Integer restaurantid) {
        restaurantMapper.normal(restaurantid);
    }

    @Override
    public void relax(Integer restaurantid) {
        restaurantMapper.relax(restaurantid);
    }

    @Override
    public List<Restaurant> getallnormalres() {
        return  restaurantMapper.getallnormalres();

    }

    @Override
    public List<User> getclient(String restaurantid) {
        return  restaurantMapper.getclient(restaurantid);
    }

    @Override
    public List<Restaurant> reccommendation(Integer userid, Integer usertypeid) {
        return restaurantMapper.reccommendation(usertypeid,userid);
    }
    @Override
    public Double getmoney(String restaurantid) {
        return  restaurantMapper.getmoney(restaurantid);
    }

    @Override
    public void updatemoney(Double money, String restaurantid) {
        restaurantMapper.updatemoney(money,restaurantid);
    }

}
